package com.ds.infrastructure.hyperspace.console.dto.apirouter;

import com.ds.infrastructure.hyperspace.console.dto.configdata.NodesDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author: yaozhendong
 * @create: 2019-12-11 10:28
 **/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ApiRouterTargetNodesDTO extends ApiRouterNodesDTO implements Serializable {

    private String resolverType;
    private String servicePath;
    private ApiRouterTargetProtocolConfig protocolConfig;

    public static ApiRouterTargetNodesDTO toApiRouter(NodesDTO dto) {
        ApiRouterTargetNodesDTO apiRouterTargetNodesDTO = new ApiRouterTargetNodesDTO();
        apiRouterTargetNodesDTO.setProtocol(dto.getProtocol());
        apiRouterTargetNodesDTO.setHost(dto.getHost());
        apiRouterTargetNodesDTO.setZone(dto.getZone());
        apiRouterTargetNodesDTO.setPort(dto.getPort());
        apiRouterTargetNodesDTO.setResolverType(dto.getResolverType());
        apiRouterTargetNodesDTO.setServicePath(dto.getServicePath());
        apiRouterTargetNodesDTO.setProtocolConfig(ApiRouterTargetProtocolConfig.toApiRouter(dto));
        return apiRouterTargetNodesDTO;
    }
}
